using System;
using System.Data.Entity.ModelConfiguration;
using System.Data.Common;
using System.Data.Entity;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using HISModels.Entities;

namespace HISModels.Mapping
{
	public class WorkflowApprovalMap : EntityTypeConfiguration<WorkflowApproval>
	{
		public WorkflowApprovalMap()
		{
			// Primary Key
			this.HasKey(t => t.Id);

			// Properties
			// Table & Column Mappings
			this.ToTable("WorkflowApprovals");
			this.Property(t => t.Id).HasColumnName("Id");
			this.Property(t => t.SeqOrder).HasColumnName("SeqOrder");
			this.Property(t => t.EmployeeId).HasColumnName("EmployeeId");
			this.Property(t => t.WorkflowStatusId).HasColumnName("WorkflowStatusId");
			this.Property(t => t.ActionDate).HasColumnName("ActionDate");
			this.Property(t => t.WorkflowId).HasColumnName("WorkflowId");

			// Relationships
			this.HasOptional(t => t.Workflow)
				.WithMany(t => t.WorkflowApprovals)
				.HasForeignKey(d => d.WorkflowId);
				
			this.HasOptional(t => t.WorkflowStatus)
				.WithMany(t => t.WorkflowApprovals)
				.HasForeignKey(d => d.WorkflowStatusId);
				
		}
	}
}

